//
//  CSMyOrderConfirmingTVC.m
//  ProjectforHDX
//
//  Created by wusiping on 16/8/8.
//  Copyright © 2016年 H.DX. All rights reserved.
//  @"订单详情"

#import "CSMyOrderConfirmingTVC.h"
#import "CSMyOrderHeadV.h"
#import "DeliveryModel.h"
#import "CSMyOrderConfirmingCell.h"
#import "CSMyOrderFootView.h"
#import "DeliveryFV.h"
#import "BottomOperationView.h"

//修改
#import "CSNewOrderLCVC.h"
#import "CSNewOrderServiceVC.h"
#import "CSNewOrderManageVC.h"
#import "CSNewOrderReplaceVC.h"

//安排发货
#import "DeliveryPartReplaceVC.h"
#import "CSSettleDeliveryUpdatePlateTVC.h"

//查看物流
#import "CMyOrderCenterDetailCheck.h"
#import "DeliverModel.h"

//查看excel
#import "ExcelWebView.h"





@interface CSMyOrderConfirmingTVC ()<UITableViewDataSource,UITableViewDelegate,MWPhotoBrowserDelegate>{
    NSMutableArray *photos;
    UIView *bottomView;
    UIDatePicker *datePicker;
    UIToolbar *toolBar;
    NSString *titleStr;
}
@property (nonatomic, strong)UITableView *tableView;

/**
 *  订单状态字典  13按时送达  14延时送达
 */
@property (nonatomic, strong)NSMutableDictionary *orderStatusDic;
/**
 *  收货人信息字典
 */
@property (nonatomic, strong)NSMutableDictionary *receiverDict;

/**
 *  物流信息字典
 */
@property (nonatomic, strong)NSMutableDictionary *logisticsDict;

/**
 *  板件字典
 */
@property (nonatomic, strong)NSMutableDictionary *partsDict;


@property (nonatomic, strong)NSMutableDictionary *customerServiceDict;


/**
 *  板件数组
 */
@property (nonatomic, strong)NSMutableArray *dataArray;

/**
 *  1准时送达  2延时送达
 */
@property (nonatomic, strong)NSString *arriveStatus;

/**
 *  底部控件
 */
@property (nonatomic, strong)UIView *bottomView;

@property (nonatomic, strong)NSMutableArray *takeArray;

/**
 *  高度数组
 */
@property (nonatomic, strong) NSMutableArray *heightArray;

@property (nonatomic, strong) UIView *maskView;
@end

@implementation CSMyOrderConfirmingTVC
static NSMutableDictionary *dict;
static NSString *CSMyOrderConfirmingCellID = @"CSMyOrderConfirmingCell";

-(NSMutableArray *)dataArray
{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc]init]];
    [self getOrderDetails];


}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"视图加载后的高度%f",self.view.height);

}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setShadowImage:nil];
}
- (void)viewDidLoad {
    NSLog(@"视图加载前的高度%f",self.view.height);
    titleStr = [THMangerTool language:@"show.WarmTip"];
    [super viewDidLoad];
    
    
    [self UIConfig];

}

- (void)navigationBackButton{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark 网络请求
/**
 *  获取订单详情
 */
- (void)getOrderDetails {
        
    [[BDHUD sharedManager] showBDHUD:self.view title:nil];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"orderCode"]=self.orderCode;
    [AFHttpTool postJsonDatawithUrl:@"orderDetail"  parameters:[params mutableCopy] success:^(id responseObject) {
        
        [[BDHUD sharedManager] dismissHUD];
        
        if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
           dict = [[NSMutableDictionary alloc]initWithDictionary: [responseObject objectForKey:@"data"]];
            NSLog(@"%@",dict);
            if (dict != nil) {
                [self dataConfig:dict];
                
                {
                    self.takeArray = [NSMutableArray array];
                    for (int i = 0;  i < [dict[@"parts"][@"faultParts"] count]; i++) {
                        [self.takeArray addObject:@"0"];
                    }
                    
                }
                
                [self.tableView reloadData];
                [self setupHeadViewAndBottomView];
                [self setUpArriveStatus];
            }
            else {
                self.tableView.tableHeaderView = nil;
                [[BDHUD sharedManager] showNOneDataViewHUD:self.tableView  top:30 title:[THMangerTool language:@"HUD.noOrderData"]  onClick:nil];
            }
        }
        else {
            
            //返回数据出问题 弹出服务器返回信息
            if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            }
        }
        
    } fail:^(id responseObject, NSError *error) {
        
        [[BDHUD sharedManager] dismissHUD];
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }


    }];
}

/**
 *  取消订单
 */
- (void)cancelOrderDetails {
    
    [[BDHUD sharedManager] showBDHUD:self.view title:nil];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"orderCode"]=self.orderCode;
    [AFHttpTool postJsonDatawithUrl:@"cancelOrder"  parameters:[params mutableCopy] success:^(id responseObject) {
        
        [[BDHUD sharedManager] dismissHUD];
        
        if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
            
            [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            [self.navigationController popViewControllerAnimated:YES];

        }
        else {
            
            //返回数据出问题 弹出服务器返回信息
            if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            }
        }
    } fail:^(id responseObject, NSError *error) {
        
        [[BDHUD sharedManager] dismissHUD];
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
    }];
}

/**
 *确认订单前，先调查询订单是否有足够库存接口
 */
- (void)comfirmInventoryIsEnough{
    
    [[BDHUD sharedManager] showBDHUD:self.view title:nil];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"orderCode"]=self.orderCode;
    [AFHttpTool postJsonDatawithUrl:@"inventoryIsEnough"  parameters:[params mutableCopy] success:^(id responseObject) {
        
        NSLog(@"确认订单信息%@",responseObject);
        
        [[BDHUD sharedManager] dismissHUD];
        
        if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
            
            if ([[[responseObject objectForKey:@"data"] objectForKey:@"flag"] integerValue] == 0) {
                
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"%@\n 是否继续确认订单?" ,[[responseObject objectForKey:@"data"] objectForKey:@"message"]]preferredStyle:UIAlertControllerStyleAlert];
                
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
                UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                    [self confirmOrderDetails];
                }];
                
                [alertController addAction:cancelAction];
                [alertController addAction:okAction];
                
                [self presentViewController:alertController animated:YES completion:nil];
                
            }
            else{
                [self confirmOrderDetails];
            }
        }
        else {
            //返回数据出问题 弹出服务器返回信息
            if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            }
        }
        
    } fail:^(id responseObject, NSError *error) {
        
        [[BDHUD sharedManager] dismissHUD];
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
        
        
    }];

}

/**
 *  确认订单
 */
- (void)confirmOrderDetails {
    
    [[BDHUD sharedManager] showBDHUD:self.view title:nil];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"orderCode"]=self.orderCode;
    [AFHttpTool postJsonDatawithUrl:@"confirmOrder"  parameters:[params mutableCopy] success:^(id responseObject) {
        
        [[BDHUD sharedManager] dismissHUD];
        
        if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
            
            [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            [self getOrderDetails];
            [self.tableView reloadData];
        }
        else {
            
            //返回数据出问题 弹出服务器返回信息
            if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            }
        }
        
    } fail:^(id responseObject, NSError *error) {
        
        [[BDHUD sharedManager] dismissHUD];
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
        
        
    }];
}

/**
 *  确认收货
 */
- (void)confirmReceive {
    
    [[BDHUD sharedManager] showBDHUD:self.view title:nil];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"orderCode"]=self.orderCode;
    params[@"receiveDate"] = titleStr;
    if (self.arriveStatus == nil) {
        [Toolobject showAlterwithMessage:@"请选择送达状态"];
    }
    [params setValue:self.arriveStatus forKey:@"result"];
    [AFHttpTool postJsonDatawithUrl:@"confirmReceive"  parameters:[params mutableCopy] success:^(id responseObject) {
        
        [[BDHUD sharedManager] dismissHUD];
        
        if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
            
            [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            [self getOrderDetails];
            [self.tableView reloadData];

            
        }
        else {
            
            //返回数据出问题 弹出服务器返回信息
            if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
            }
        }
        
    } fail:^(id responseObject, NSError *error) {
        
        [[BDHUD sharedManager] dismissHUD];
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
        
        
    }];
    
}


#pragma mark 初始化
- (void)dataConfig:(NSDictionary *)dict{
    
    self.orderStatusDic  = [dict objectForKey:@"orderStatus"];
    self.receiverDict = [dict objectForKey:@"receiver"];
    self.deliveryModel = [[DeliveryModel alloc] init];
    self.deliveryModel.orderStatus = [[NSMutableDictionary alloc]initWithDictionary: [dict objectForKey:@"orderStatus"]];
    self.deliveryModel.receiver = [[NSMutableDictionary alloc]initWithDictionary:[dict objectForKey:@"receiver"]];
    self.deliveryModel.isSameTime = [dict objectForKey:@"isSameTime"];
    self.deliveryModel.logistics = [[NSMutableDictionary alloc]initWithDictionary:[dict objectForKey:@"logistics"]];
    self.deliveryModel.remark = [dict objectForKey:@"remark"];
    self.deliveryModel.takeZheTime = [dict objectForKey:@"takeZheTime"];
    self.deliveryModel.parts = [[NSMutableDictionary alloc]initWithDictionary:[dict objectForKey:@"parts"]];
    
    self.customerServiceDict = [[NSMutableDictionary alloc]initWithDictionary:[dict objectForKey:@"customerService"]];             
    
    self.logisticsDict = [[NSMutableDictionary alloc]initWithDictionary:[dict objectForKey:@"logistics"]];

    self.dataArray = [self.deliveryModel.parts objectForKey:@"faultParts"];
    self.heightArray = [[NSMutableArray alloc]init];
    
    for (long i = 0 ; i < self.dataArray.count ; i ++ ) {
        CSMyOrderConfirmingCell *cell= [[CSMyOrderConfirmingCell alloc] init];
        [cell setData:self.deliveryModel.parts andOrderStatus:self.deliveryModel.orderStatus];
        cell.index = i;
        CGFloat heigt=  [cell createStepView];
        NSString *heightStr = [NSString stringWithFormat:@"%f",heigt];
        NSLog(@"cell的高度是%@",self.deliveryModel.orderStatus);
        [self.heightArray addObject:heightStr];
    }  

    
    
}


- (void)UIConfig{
    
    
    self.labnav.text = [UtilCheck language:@"order.detail"];
    self.labnav.textColor = [UIColor whiteColor];
    self.labnav.backgroundColor = [UIColor clearColor];
    self.view.backgroundColor = [UIColor whiteColor];
    

    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0  ,self.view.width , self.view.height - 64 - 52)];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
  
    [self.tableView registerClass:[CSMyOrderConfirmingCell class] forCellReuseIdentifier:CSMyOrderConfirmingCellID];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    
    
   
}

#pragma mark 添加按时送达延时送达
- (void)setUpArriveStatus{
    
    UIImageView *arriveStatusImageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.width - 95, 100, 95, 80)];

    
    if ([[self.orderStatusDic objectForKey:@"status"] integerValue ] == 14 ||[[self.orderStatusDic objectForKey:@"status"] integerValue ] == 15) {
        NSString *str = [NSString stringWithFormat:@"/Order/%@",[THMangerTool language:@"show.late"]];
        arriveStatusImageView.image = BDFILEIMAGENAEM(str);
        
    }
    else if ([[self.orderStatusDic objectForKey:@"status"] integerValue ] == 13 || [[self.orderStatusDic objectForKey:@"status"] integerValue ] == 16){
        NSString *str = [NSString stringWithFormat:@"/Order/%@",[THMangerTool language:@"show.on.time"]];
        arriveStatusImageView.image = BDFILEIMAGENAEM(str);
    }
    
    
    arriveStatusImageView.alpha = 0;
    
    [self.view addSubview:arriveStatusImageView];
    [self.view bringSubviewToFront:arriveStatusImageView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0];
    arriveStatusImageView.alpha = 1;
    
    [UIView commitAnimations];

    
}
#pragma mark 创建头部和底部控件
-(void)setupHeadViewAndBottomView
{

    //跟随滚动
    NSString *yesOrNo;
    if ([self.deliveryModel.isSameTime isEqualToString:@"0"]) {
        yesOrNo = [UtilCheck language:@"order.no"];
    }else{
        yesOrNo = [UtilCheck language:@"order.yes"];
    }
    
    CSMyOrderHeadV *headView = [[CSMyOrderHeadV alloc]initHeaderViewWithOrderStatusDic: self.deliveryModel.orderStatus  AndReceiverDict:self.deliveryModel.receiver AndlogisticsDict:self.deliveryModel.logistics AndCustomerServiceDict:self.customerServiceDict];
    self.tableView.tableHeaderView = headView;
    self.tableView.bounces = NO;
    

    
    CSMyOrderFootView *footView = [[CSMyOrderFootView alloc]initFootViewWithIsSameTime:yesOrNo AndRemark:self.deliveryModel.remark AndRemark:self.deliveryModel.takeZheTime AndLogistics:self.deliveryModel.logistics AndOrderType:self.deliveryModel.orderStatus];
    self.tableView.tableFooterView = footView;
    
    NSLog(@"______________%@",self.deliveryModel.takeZheTime);
    
    NSArray *arr= [[self.deliveryModel.orderStatus objectForKey:@"operation"] componentsSeparatedByString:@","];
    
    NSLog(@"______________%@",arr);

    
    //要哪个改一下数字 "operation":操作权限，
//    1取消订单2修改订单，3安排发货，4确认订单，5继续发货，6确认收货，7查看物流
//    NSArray *arr = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",nil];
    if (self.bottomView) {
        [self.bottomView removeFromSuperview];
    }
    
    if (arr.count == 1 && [arr[0] length] <= 0) {
        
        [self.tableView setFrame:CGRectMake(0, 0  ,self.view.width , self.view.height)];
        return ;
    }

    self.bottomView = [[UIView alloc]init];
    BottomOperationView *bottomView = [[BottomOperationView alloc]initWithOperationArray:arr AndOperationType:@"order" btnClick:^(long tag) {
        [self btnClick:tag];
    }];
    self.bottomView = bottomView;
    [self.view addSubview:self.bottomView];
    [self.bottomView setFrame:CGRectMake(0, self.view.height - 52, self.view.width, 52)];
    
    [self.tableView setBackgroundColor:[Toolobject getColorByRGB:246 green:247 blue:248 alpha:1]];
    
}

#pragma mark 底部按钮点击
/**
 *  按钮点击
 "operation":操作权限，1取消订单2修改订单，3安排发货，4确认订单，5继续发货，6确认收货，7查看物流，8快速发货，9发货,10.通知取故障件(只有本地客户有此权限)
 *  @param sender
 */
-(void)btnClick:(long)sender{
    
    [dict objectForKey:@"logisticsInfo"];
    
    THUserInfoModel *userModel=[THMangerTool getAccountInfo];

    switch (sender) {
        case 1://取消订单
        {
            
            
            [self cancelOrderDetails];
        }
            break;
        case 2://修改订单
        {
            
            [userModel.userType integerValue];
           
            if ([userModel.userType integerValue] == 1) {//客户
                if ([[self.orderStatusDic objectForKey:@"type"] integerValue] == 1){
                    CSNewOrderManageVC *vc = [[CSNewOrderManageVC alloc]init];
                    vc.dict = dict;
                    vc.order = 1;
                    [self.navigationController pushViewController:vc animated:YES];
                }else{
                    CSNewOrderReplaceVC *vc = [[CSNewOrderReplaceVC alloc]init];
                    vc.dict = dict;
                    vc.order = 1;
                    [self.navigationController pushViewController:vc animated:YES];   // 数据完成
                }
                
            }else if ([userModel.userType integerValue] == 2 || [userModel.userType integerValue] == 0) {//客服  admin
                if ([[self.orderStatusDic objectForKey:@"type"] integerValue] == 1) {//备件管理服务
                    CSNewOrderServiceVC *vc = [[CSNewOrderServiceVC alloc]init];
                    vc.dict = dict;
                    vc.order = 1;
                    [self.navigationController pushViewController:vc animated:YES];

                    //数据完成
                }else{
                    
                    CSNewOrderLCVC *vc = [[CSNewOrderLCVC alloc]init];
                    vc.dict = dict;
                    vc.order = 1;
                    [self.navigationController pushViewController:vc animated:YES];
                }
            }else {// 仓管
                NSLog(@"进入修改时，状态不对");
            }
            
        }
            break;
        case 3://安排发货
        {
            

//            if ([userModel.userType integerValue] == 2) {//客服
//                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
//                view.orderCode = self.orderCode;
//                view.logisticsInfo = self.logisticsDict;
//                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
//                [self.navigationController pushViewController:view animated:YES];
// 
//            }else{
//                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
//                vc.orderCode = self.orderCode;
//                [self.navigationController pushViewController:vc animated:YES];
//            }
//            
            if ([userModel.servicePermissions[0] integerValue] == 1) {//可修改
                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
                view.orderCode = self.orderCode;
                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
                
                [self.navigationController pushViewController:view animated:YES];
                
            }else{
                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
                vc.orderCode = self.orderCode;
                [self.navigationController pushViewController:vc animated:YES];
            }


        }
            break;
        case 4://确认订单
        {
            [self comfirmInventoryIsEnough];
        }
            break;
        case 5://继续发货
        {
//            if ([userModel.userType integerValue] == 2) {//客服
//                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
//                view.orderCode = self.orderCode;
//                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
//
//                [self.navigationController pushViewController:view animated:YES];
//                
//            }else{
//                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
//                vc.orderCode = self.orderCode;
//                [self.navigationController pushViewController:vc animated:YES];
//            }
            
            
            if ([userModel.servicePermissions[0] integerValue] == 1) {//可修改
                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
                view.orderCode = self.orderCode;
                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
                
                [self.navigationController pushViewController:view animated:YES];
                
            }else{
                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
                vc.orderCode = self.orderCode;
                [self.navigationController pushViewController:vc animated:YES];
            }


        }
            break;
        case 6://确认收货
        {
            bottomView = [[UIView alloc]init];
            [bottomView setFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
            [bottomView setBackgroundColor:[UIColor colorWithWhite:0.f alpha:0.5 ]];
            [self.view addSubview:bottomView];
            
            UIView *alertView = [[UIView alloc]init];
            [alertView setFrame:CGRectMake((self.view.width-280)/2, (self.view.height-150)/2, 280, 180)];
            [alertView setBackgroundColor:[UIColor whiteColor]];
            [alertView.layer setCornerRadius:20];
            [alertView.layer setMasksToBounds:YES];
            [bottomView addSubview:alertView];
            
            UIView * headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, alertView.bounds.size.width, 50)];
            headView.backgroundColor = [UtilCheck hexStringToColor:@"9ed4e2" alpha:1];
            [alertView addSubview:headView];
            UIImageView *headImageView = [[UIImageView alloc]initWithFrame:CGRectMake((headView.bounds.size.width - 60) / 2, 5, 44, 44)];
            headImageView.image = BDFILEIMAGENAEM(@"Order/img_pack.png");
            [headView addSubview:headImageView];
            
            UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, headImageView.bounds.size.height+5, alertView.bounds.size.width, 44)];
            titleLabel.text = [UtilCheck language:@"show.evaluation"];
            titleLabel.textColor = [UIColor blackColor];
            [titleLabel setTextAlignment:(NSTextAlignmentCenter)];
            [titleLabel setFont:[UIFont systemFontOfSize:16]];
            [alertView addSubview:titleLabel];
            
            UIButton *title = [[UIButton alloc]initWithFrame:CGRectMake(30, titleLabel.bounds.size.height+40, alertView.width-60, 44)];
            [title setTitle:titleStr forState:(UIControlStateNormal)];
            [title setTitle:titleStr forState:(UIControlStateHighlighted)];
            [title setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:(UIControlStateNormal)];
            [title.titleLabel setFont:[UIFont systemFontOfSize:18]];
            title.titleLabel.textAlignment = UITextAlignmentCenter;
            [title addTarget:self action:@selector(ActualDeliveryTime) forControlEvents:(UIControlEventTouchUpInside)];
            [alertView addSubview:title];
            
            // 确认和修改
            UIButton *confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
            confirmButton.frame = CGRectMake(0, alertView.bounds.size.height - 38, alertView.bounds.size.width / 2 - 1, 40);
            [confirmButton setTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.OnTime"] forState:UIControlStateNormal];
            [confirmButton setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:UIControlStateNormal];
            [confirmButton addTarget:self action:@selector(cancelButtonTitle) forControlEvents:UIControlEventTouchUpInside];
            [alertView addSubview:confirmButton];
            
            UIButton *modifyButton = [UIButton buttonWithType:UIButtonTypeCustom];
            modifyButton.frame = CGRectMake(alertView.bounds.size.width / 2, alertView.bounds.size.height - 38, alertView.bounds.size.width / 2, 40);
            [modifyButton setTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.Delayed"] forState:UIControlStateNormal];
            [modifyButton setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:UIControlStateNormal];
            [modifyButton addTarget:self action:@selector(otherButtonTitles) forControlEvents:UIControlEventTouchUpInside];
            [alertView addSubview:modifyButton];
            
            UILabel *rightTopLine = [[UILabel alloc]initWithFrame:CGRectMake(0, modifyButton.frame.origin.y-5, bottomView.bounds.size.width, 0.5)];
            [rightTopLine setBackgroundColor:[UIColor grayColor]];
            [alertView addSubview:rightTopLine];
            UILabel *leftTopLine = [[UILabel alloc]initWithFrame:CGRectMake(0, modifyButton.frame.origin.y-5, bottomView.bounds.size.width, 0.5)];
            [leftTopLine setBackgroundColor:[UIColor grayColor]];
            [alertView addSubview:leftTopLine];
            UILabel *alignmentLine = [[UILabel alloc]initWithFrame:CGRectMake(modifyButton.frame.origin.x+1, modifyButton.frame.origin.y-5, 0.5, modifyButton.frame.origin.y+5)];
            [alignmentLine setBackgroundColor:[UIColor grayColor]];
            [alertView addSubview:alignmentLine];
            
            
//            UIView *alertView = [[UIView alloc]init];
//            [alertView setFrame:CGRectMake((self.view.width-280)/2, (self.view.height-150)/2, 280, 150)];
//            [alertView setBackgroundColor:[UIColor whiteColor]];
//            [alertView.layer setCornerRadius:20];
//            [alertView.layer setMasksToBounds:YES];
//            [bottomView addSubview:alertView];
//            
//            UILabel *Line = [[UILabel alloc]init];
//            [Line setBackgroundColor:[UtilCheck hexStringToColor:@"e8e8e8" alpha:1]];
//            [Line setFrame:CGRectMake(0, 150-44, 280, 0.5)];
//            [alertView addSubview:Line];
//            UILabel *verticalLine = [[UILabel alloc]init];
//            [verticalLine setBackgroundColor:[UtilCheck hexStringToColor:@"e8e8e8" alpha:1]];
//            [verticalLine setFrame:CGRectMake(280/2, 150-44, 0.5, 44)];
//            [alertView addSubview:verticalLine];
//            
//            UIButton *title = [[UIButton alloc]initWithFrame:CGRectMake(30, 50, alertView.width-60, 44)];
////            title.textAlignment = UITextAlignmentCenter;
////            [title setFont:[UIFont systemFontOfSize:13]];
////            title.text = [THMangerTool language:@"show.WarmTip"];
//            [title setTitle:titleStr forState:(UIControlStateNormal)];
//            [title setTitle:titleStr forState:(UIControlStateHighlighted)];
//            [title setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:(UIControlStateNormal)];
////            [title.layer setBorderWidth:0.5];
////            [title.layer setBorderColor:[UIColor blackColor].CGColor];
//            [title.layer setMasksToBounds:YES];
//            [title.layer setCornerRadius:5.0];
//            [title.titleLabel setFont:[UIFont systemFontOfSize:18]];
//            title.titleLabel.textAlignment = UITextAlignmentCenter;
//            
//            [title addTarget:self action:@selector(ActualDeliveryTime) forControlEvents:(UIControlEventTouchUpInside)];
//            [alertView addSubview:title];
//            UILabel *message = [[UILabel alloc]initWithFrame:CGRectMake(0, title.height-45, alertView.width, 60)];
//            message.textAlignment = UITextAlignmentCenter;
//            [message setFont:[UIFont systemFontOfSize:18]];
//            message.text = [THMangerTool language:@"CSMyOrderConfirmingTVC.DeliveredOnTime"];
//            [alertView addSubview:message];
//
//            UIButton *cancelButtonTitle = [UIButton buttonWithType:(UIButtonTypeCustom)];
//            [cancelButtonTitle setFrame:CGRectMake(0, Line.bottom, alertView.width/2, 44)];
//            [cancelButtonTitle setTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.OnTime"] forState:(UIControlStateNormal)];
//            [cancelButtonTitle setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:(UIControlStateNormal)];
//            [cancelButtonTitle addTarget:self action:@selector(cancelButtonTitle) forControlEvents:(UIControlEventTouchUpInside)];
//            [alertView addSubview:cancelButtonTitle];
//            UIButton *otherButtonTitles = [UIButton buttonWithType:(UIButtonTypeCustom)];
//            [otherButtonTitles setFrame:CGRectMake(cancelButtonTitle.right, Line.bottom, alertView.width/2, 44)];
//            [otherButtonTitles setTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.Delayed"] forState:(UIControlStateNormal)];
//            [otherButtonTitles setTitleColor:[UtilCheck hexStringToColor:@"1CB0F6" alpha:1] forState:(UIControlStateNormal)];
//            [otherButtonTitles addTarget:self action:@selector(otherButtonTitles) forControlEvents:(UIControlEventTouchUpInside)];
//            [alertView addSubview:otherButtonTitles];
            
//            UIAlertController *alert = [UIAlertController alertControllerWithTitle:[THMangerTool language:@"show.WarmTip"] message:[THMangerTool language:@"CSMyOrderConfirmingTVC.DeliveredOnTime"] preferredStyle:UIAlertControllerStyleAlert];
//            [self presentViewController:alert animated:YES completion:nil];
//            [alert addAction:[UIAlertAction actionWithTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.OnTime"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//                self.arriveStatus = @"1";
//                [self confirmReceive];
//                
//            }]];
//            
//            [alert addAction:[UIAlertAction actionWithTitle:[THMangerTool language:@"CSMyOrderConfirmingTVC.Delayed"] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//                self.arriveStatus = @"2";
//                [self confirmReceive];
//
//            }]];
            
            
        }
            break;
        case 7://查看物流
        {
            DeliverModel *model = [[DeliverModel alloc]init];
            
            if ([self.logisticsDict[@"logisticsInfo"] isKindOfClass:[NSDictionary class]]) {
                model.com =  self.logisticsDict[@"logisticsInfo"][@"com"];
                model.code = self.logisticsDict[@"logisticsInfo"][@"expressCode"];

            }
            else{
                model.com =  @"";
                model.code = @"";
 
            }
            
            if ([model.com isEqualToString:@"其他"]||[model.com isEqualToString:@"other"]) {
                [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.noCom"]];
            }
            else {
                CMyOrderCenterDetailCheck *vc = [[CMyOrderCenterDetailCheck alloc]init];
                [vc setDeliver:model];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }
            break;
            
        case 9://发货
        {
//            if ([userModel.userType integerValue] == 2) {//客服
//                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
//                view.orderCode = self.orderCode;
//                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
//
//                [self.navigationController pushViewController:view animated:YES];
//                
//            }else{
//                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
//                vc.orderCode = self.orderCode;
//                [self.navigationController pushViewController:vc animated:YES];
//            }
            
            if ([userModel.servicePermissions[0] integerValue] == 1) {//可修改
                CSSettleDeliveryUpdatePlateTVC *view = [[CSSettleDeliveryUpdatePlateTVC alloc]init];
                view.orderCode = self.orderCode;
                view.badPlateNum = [[self.deliveryModel.parts objectForKey:@"faultPartNum"] integerValue];
                
                [self.navigationController pushViewController:view animated:YES];

            }else{
                DeliveryPartReplaceVC *vc = [[DeliveryPartReplaceVC alloc]init];
                vc.orderCode = self.orderCode;
                [self.navigationController pushViewController:vc animated:YES];
            }
            
            
            
            
        }
            break;

        case 10:{//通知取故障件
            NSMutableDictionary *comeOnBabyDic = [[NSMutableDictionary alloc]init];
            
            NSMutableArray *partsArray = [[NSMutableArray alloc]init];
            
            for (int i = 0; i < _takeArray.count; i++) {
                if ([_takeArray[i] intValue] == 1) {
                    
                    NSDictionary *dic = dict[@"parts"][@"faultParts"][i][@"faultPart"];
                    
                    NSDictionary *partsDic = [[NSDictionary alloc]initWithObjectsAndKeys:dic[@"plateID"],@"plateID",dic[@"plateName"],@"plateName",dic[@"plateCode"],@"plateCode",dic[@"plateVersion"],@"plateVersion",dic[@"plateSn"],@"plateSn",dic[@"stationName"],@"stationName",dic[@"rma"],@"rma",dic[@"remaining"],@"remaining", nil];
                    [partsArray addObject:partsDic];
                }
            }
            
            [comeOnBabyDic setObject:dict[@"orderStatus"][@"orderCode"] forKey:@"orderCode"];
            [comeOnBabyDic setObject:partsArray forKey:@"parts"];
            
            
            if(partsArray.count <= 0){
                [Toolobject showAlterwithMessage:[THMangerTool language:@"order.selectMessageParts"]];
                return;
            }
            
            [[BDHUD sharedManager] showBDHUD:self.view title:nil];
            [AFHttpTool postJsonDatawithUrl:@"comeOnBaby" parameters:comeOnBabyDic success:^(id responseObject) {
                [[BDHUD sharedManager] dismissHUD];
                
                NSDictionary *headDic = responseObject[@"head"];
                
                if ([headDic[@"status"] intValue] == 1) {
                    [[BDHUD sharedManager] showWords:headDic[@"info"]];
                    [self getOrderDetails];
                }
                
                
                
            } fail:^(id responseObject, NSError *error) {
                [[BDHUD sharedManager] dismissHUD];
                
                [[BDHUD sharedManager] showWords:[THMangerTool language:@"HUD.take.failure"]];
            }];
            
        }
            break;

            
        default:
            break;
    }
}



- (void)setData:(NSDictionary *)data{
}

#pragma mark  tableview



- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
 
//    CSMyOrderConfirmingCell *cell= [[CSMyOrderConfirmingCell alloc] init];
//    [cell setData:self.deliveryModel.parts andOrderStatus:self.deliveryModel.orderStatus];
//    cell.index = indexPath.row;
//    CGFloat heigt=  [cell createStepView];
//    NSLog(@"cell的高度是%f",heigt);
//    return heigt;
 
    CGFloat height = [self.heightArray[indexPath.row] doubleValue];
    return height;
 

    
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    CSMyOrderConfirmingCell  *cell = [[CSMyOrderConfirmingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CSMyOrderConfirmingCellID];;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.row = indexPath.row;
    
    cell.takeBlock = ^(NSInteger state) {
        
        self.takeArray[indexPath.row] = [NSString stringWithFormat:@"%ld",(long)state];
        
    };
    [cell setData:self.deliveryModel.parts andOrderStatus:self.deliveryModel.orderStatus];
    cell.index = indexPath.row;
    [cell RMALableClick:^(NSString *text) {
        if ([Toolobject IsEmptyString:text]) {
            return ;
        }
        
        [[BDHUD sharedManager] showBDHUD:self.view title:nil];
        
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        params[@"plateID"]=text;
        
       
        [AFHttpTool postJsonDatawithUrl:@"orderRMADetail"  parameters:[params mutableCopy] success:^(id responseObject) {
            
            [[BDHUD sharedManager] dismissHUD];
            
            if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] ) {
                
                NSMutableArray *RMADataArr = [[NSMutableArray alloc]initWithArray:[responseObject objectForKey:@"data"]];
                NSMutableArray *RMANameArr = [[NSMutableArray alloc]init];
                for (int i = 0 ; i < RMADataArr.count ; i ++) {
                    NSString *name = [RMADataArr[i] objectForKey:@"rma"];
                    [RMANameArr addObject:name];
                }
                PXAlertView *AlertView = [[PXAlertView alloc]initAlertWithTitle:@"RMA" message:nil cancelTitle:nil otherTitle:nil contentView:nil completion:nil tableview:RMANameArr];
                [AlertView show];
                
            }
            else {
                
                //返回数据出问题 弹出服务器返回信息
                if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                    [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
                }
            }
            
        } fail:^(id responseObject, NSError *error) {
            
            [[BDHUD sharedManager] dismissHUD];
            if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
                [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
            }else {
                [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
            }
            
            
        }];
    
    }];
    
    [cell describleLableClick:^(NSString *text) {
        [[BDHUD sharedManager] showBDHUD:self.view title:[UtilCheck language: @"HUD.title"]];

        text = [UtilCheck substring:text NSRange: [NSString stringWithFormat:@"%@:",[UtilCheck language:@"seeting.troubleDescribe"]] Type:1];

        NSDictionary *diction = @{@"filePath":text};
        
        [AFHttpTool postJsonDatawithUrl:@"getOrderFile"  parameters:diction success:^(id responseObject) {
            
            [[BDHUD sharedManager] dismissHUD];
            [Toolobject showTextWithMessage:@"暂无附件"];
            
        } fail:^(id responseObject, NSError *error) {
            [[BDHUD sharedManager] dismissHUD];
            NSData *data = error.userInfo[@"com.alamofire.serialization.response.error.data"];
            NSFileManager *fileManager = [NSFileManager defaultManager];
            
            //判断MyImageFolder文件夹是否存在
            BOOL fileExists = [fileManager fileExistsAtPath:UPLOAD(@"")];
            if(!fileExists)
            {
                [fileManager createDirectoryAtPath:UPLOAD(@"") withIntermediateDirectories:YES attributes:nil error:nil];
            }
            if ([text containsString:@"jpg"] || [text containsString:@"png"] || [text containsString:@"jpeg"] || [text containsString:@"bmp"] || [text containsString:@"gif"]) {//image
                NSString *fileOldPath=[NSString stringWithFormat:@"%@/DT_%@.jpg",UPLOAD(@""),[UtilCheck DateToTimestamp]];
                
                [data writeToFile:fileOldPath atomically:NO]; //写入文件
                
                UIImage *img = [UIImage imageWithData:data];
                photos=[[NSMutableArray alloc] initWithCapacity:0];
                 MWPhoto *pt=[MWPhoto photoWithImage:img] ;
                [photos addObject:pt];
                
            
                MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
                browser.displayActionButton = NO;//分享按钮,默认是
                browser.displayNavArrows = NO;//左右分页切换,默认否
                browser.displaySelectionButtons = NO;//是否显示选择按钮在图片上,默认否
                browser.alwaysShowControls = NO;//底部 顶部控制条件控件 是否显示,默认否
                browser.zoomPhotosToFill = YES;//是否全屏,默认是
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
                browser.wantsFullScreenLayout = YES;//是否全屏
#endif
                browser.enableGrid = NO;//是否允许用网格查看所有图片,默认是
                browser.startOnGrid = YES;//是否第一张,默认否
                browser.enableSwipeToDismiss = YES;
                
                [browser setCurrentPhotoIndex:0];
                
                CustomNavigationController *navCon = [[CustomNavigationController alloc] initWithRootViewController:browser];
                
                [self presentViewController:navCon animated:YES completion:nil];
                
            }
            else{//excel
                NSString *fileOldPath=[NSString stringWithFormat:@"%@/DT_%@.xls",UPLOAD(@""),[UtilCheck DateToTimestamp]];
                [data writeToFile:fileOldPath atomically:NO]; //写入文件
                
                NSURL *url = [NSURL fileURLWithPath:fileOldPath];
                ExcelWebView *vc = [[ExcelWebView alloc]init];
                vc.url = url;
                [self.navigationController pushViewController:vc animated:YES];

            }
            
        }];
    }];
    
    return cell;
 
}


#pragma mark MWPhotoBrowser delegate
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser{
    return 1;
}
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index{
    return [photos objectAtIndex:index];
}

#pragma mark 弹框点击事件
- (void)cancelButtonTitle {
    [bottomView removeFromSuperview];
    self.arriveStatus = @"1";
    if ([titleStr isEqualToString:[THMangerTool language:@"show.WarmTip"] ]) {
        titleStr = @"";
    }
    [self confirmReceive];
}
- (void)otherButtonTitles {
    [bottomView removeFromSuperview];
    self.arriveStatus = @"2";
    if ([titleStr isEqualToString:[THMangerTool language:@"show.WarmTip"] ]) {
        titleStr = @"";
    }
    [self confirmReceive];
}
- (void)ActualDeliveryTime {
    [bottomView removeFromSuperview];
    self.arriveStatus = @"3";
    UIView *maskView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.height*2)];
    maskView.backgroundColor = [UIColor whiteColor];
    maskView.alpha = 0.2f;
    self.maskView = maskView;
    [self.view addSubview:self.maskView];
    //设置选择时间的TextField
    datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 216, self.view.frame.size.width, 216)];
    datePicker.backgroundColor = [UIColor whiteColor];
    datePicker.datePickerMode = UIDatePickerModeDateAndTime;
    datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:[UtilCheck language:@"datePicker.LocalID"]]; //zh_CN
    
    toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 216 - 44, self.view.frame.size.width, 44.0f)];
    toolBar.backgroundColor = [UIColor grayColor];
    UIBarButtonItem* leftItem = [[UIBarButtonItem alloc] initWithTitle:[UtilCheck language:@"button.cancel"] style:UIBarButtonItemStyleDone target:self action:@selector(cancelAction)];
    UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem* rightItem = [[UIBarButtonItem alloc] initWithTitle:[UtilCheck language:@"button.done"] style:UIBarButtonItemStyleDone target:self action:@selector(confirmAction)];
    [toolBar setItems:@[leftItem,flexSpace,rightItem]];
    [self.view addSubview:datePicker];
    [self.view addSubview:toolBar];
}
-(void) cancelAction {
    [self.maskView removeFromSuperview];
    [datePicker removeFromSuperview];
    [toolBar removeFromSuperview];
    [self btnClick:6];
}
- (void)confirmAction {
    [self.maskView removeFromSuperview];
    [datePicker removeFromSuperview];
    [toolBar removeFromSuperview];
    
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd HH:mm";
    //选择时间不能大于当前时间
    //    NSDate *selectedDate = datePicker.date;
    //    NSDate *nowDate = [NSDate date];
    //
    //    if ([selectedDate laterDate:nowDate] == selectedDate ) {
    //        [Toolobject showTextWithMessage:@"选择的时间不能晚于当前时间"];
    //        return;
    //    }
    NSString *dateStr = [formatter stringFromDate:datePicker.date];
    titleStr = dateStr;
    [self btnClick:6];
}
@end
